﻿using System;
using Autodesk.Revit.DB;
using Autodesk.Revit.DB.Plumbing;
using Autodesk.Revit.UI.Selection;

namespace YArchitech.Revit
{
	public class HYDrainElementFilter : ISelectionFilter
	{
		public bool AllowElement(Element elem)
		{
			if (elem is FamilyInstance)
			{
				BuiltInCategory integerValue = elem.Category.Id.IntegerValue;
				if (integerValue == -2008055)
				{
					return true;
				}
				if (integerValue == -2001160)
				{
					return true;
				}
			}
			if (elem is Pipe)
			{
				Pipe pipe = elem as Pipe;
				double value = (pipe.Location as LocationCurve).Curve.GetEndPoint(0).X - (pipe.Location as LocationCurve).Curve.GetEndPoint(1).X;
				double value2 = (pipe.Location as LocationCurve).Curve.GetEndPoint(0).Y - (pipe.Location as LocationCurve).Curve.GetEndPoint(1).Y;
				if (Math.Abs(value) < 0.0001 && Math.Abs(value2) < 0.0001)
				{
					return true;
				}
			}
			return false;
		}

		public bool AllowReference(Reference reference, XYZ position)
		{
			return false;
		}
	}
}
